﻿/*+===================================================================
File:      BossTwoHand.cpp

Summary:   Định nghĩa các phương thức của BossTwoHand.
===================================================================+*/

#include "BossTwoHand.h"

CBossTwoHand::CBossTwoHand(CBill* bill, D3DXVECTOR2 pos, int id, int typeId) : CMoveableObject(pos, id, typeId)
{

	for (int i = 0; i < 5; i++)
	{
		if (typeId == ID_BOSS_TWO_LEFT_HAND)
		{
			if (i == 4)
				m_arms[i] = new CBossTwoLeftPartArm(bill, D3DXVECTOR2(425.0f, 4174.0f), i, ID_BOSS_TWO_ARM_HEAD);
			else
				m_arms[i] = new CBossTwoLeftPartArm(bill, D3DXVECTOR2(425.0f, 4174.0f), i, ID_BOSS_TWO_ARM_BODY);
		}
		else if (typeId == ID_BOSS_TWO_RIGHT_HAND)
		{
			if (i == 4)
				m_arms[i] = new CBossTwoRightPartArm(bill, D3DXVECTOR2(214.0f, 4174.0f), i, ID_BOSS_TWO_ARM_HEAD);
			else
				m_arms[i] = new CBossTwoRightPartArm(bill, D3DXVECTOR2(214.0f, 4174.0f), i, ID_BOSS_TWO_ARM_BODY);
		}
	}

	for (int i = 0; i < 5; i++)
	{
		if (i == 0)
		{
			m_arms[i]->prevPartArm = NULL;
			m_arms[i]->nextPartArm = m_arms[1];
		}
		else if (i == 4)
		{
			m_arms[i]->prevPartArm = m_arms[3];
			m_arms[i]->nextPartArm = NULL;
		}
		else
		{
			m_arms[i]->prevPartArm = m_arms[i-1];
			m_arms[i]->nextPartArm = m_arms[i+1];
		}
	}
}


CBossTwoHand::~CBossTwoHand()
{
}


void CBossTwoHand::Update(float timeFrame)
{
	if (!m_bIsLive)
		return;

	for (int i = 0; i < 5; i++)
	{
		m_arms[i]->Update(timeFrame);
	}
}

void CBossTwoHand::UpdateCollision(vector<CGameObject*> vecGameObjs, float timeFrame)
{
	if (!m_bIsLive)
		return;

	m_arms[4]->UpdateCollision(vecGameObjs, timeFrame);
}

void CBossTwoHand::Draw()
{
	if (!m_bIsLive)
		return;

	for (int i = 0; i < 5; i++)
	{
		m_arms[i]->Draw();
	}
}

bool CBossTwoHand::Kill()
{
	if (m_arms[4]->IsLive())
	{
		m_arms[4]->SetLife(0);
		m_arms[4]->Kill();

		return true;
	}

	return false;
}

int CBossTwoHand::GetHandStatus()
{
	return m_arms[1]->GetStatus();
}

CBossTwoPartArm* CBossTwoHand::GetHeadArm()
{
	return m_arms[4];
}